<?php
 
      class Somi_Form_SubForm extends Zend_Form
 
      {

          public function init()

          {

              // Erstellt die Benutzer Subform: Benutzername und Passwort
  
              $user = new Zend_Form_SubForm();
 
              $user->addElements(array(

                  new Zend_Form_Element_Text('username', array(

                      'required'   => true,

                      'label'      => 'Benutzername:',

                      'filters'    => array('StringTrim', 'StringToLower'),

                      'validators' => array(

                          'Alnum',

                          array('Regex',

                                false,

                                array('/^[a-z][a-z0-9]{2,}$/'))

                      )

                  )),
  
       
 
                  new Zend_Form_Element_Password('password', array(
  
                      'required'   => true,

                      'label'      => 'Passwort:',

                      'filters'    => array('StringTrim'),
 
                      'validators' => array(
  
                          'NotEmpty',
  
                          array('StringLength', false, array(6))

                      )
 
                  )),
 
              ));

       

              // Erstellt die Demographische Subform: Vorname,

              // Familienname und Ort
 
              $demog = new Zend_Form_SubForm();

              $demog->addElements(array(

                  new Zend_Form_Element_Text('givenName', array(

                      'required'   => true,

                      'label'      => 'Vorname (erster):',

                      'filters'    => array('StringTrim'),

                      'validators' => array(

                          array('Regex',

                                false,

                                array('/^[a-z][a-z0-9., \'-]{2,}$/i'))

                      )

                  )),

       

                  new Zend_Form_Element_Text('familyName', array(

                      'required'   => true,

                      'label'      => 'Familienname (letzter):',

                      'filters'    => array('StringTrim'),

                      'validators' => array(

                          array('Regex',

                                false,

                                array('/^[a-z][a-z0-9., \'-]{2,}$/i'))

                      )

                  )),

       

                  new Zend_Form_Element_Text('location', array(

                      'required'   => true,

                      'label'      => 'Der eigene Ort:',

                      'filters'    => array('StringTrim'),

                      'validators' => array(
 
                          array('StringLength', false, array(2))

                      )

                  )),

              ));

       
 
              // Erstellt die Mailinglisten Subform

              $listOptions = array(
  
                  'none'        => 'keine Listen bitte',

                  'fw-general'  => 'Zend Framework General Liste',

                  'fw-mvc'      => 'Zend Framework MVC Liste',

                  'fw-auth'     => 'Zend Framework Authentication und ACL Liste',

                  'fw-services' => 'Zend Framework Web Services Liste',
 
              );
 
              $lists = new Zend_Form_SubForm();

              $lists->addElements(array(

                  new Zend_Form_Element_MultiCheckbox('subscriptions', array(

                      'label'        =>

                          'Welche Liste wollen Sie erhalten?',
 
                      'multiOptions' => $listOptions,

                      'required'     => true,

                      'filters'      => array('StringTrim'),

                      'validators'   => array(

                          array('InArray',

                                false,

                                array(array_keys($listOptions)))

                      )

                  )),

              ));

       

              // Die Subformen der Hauptform anhängen

              $this->addSubForms(array(

                  'user'  => $user,

                  'demog' => $demog,

                  'lists' => $lists

              ));
          }
      }